﻿
@{
    ViewBag.Title = "BizTypeAdd";
    Layout = "~/Views/Shared/layoutCommon.cshtml";
}


@section style{
    <style>
        .form-horizontal .control-label {
            width: 20%;
            float: left;
            text-align: right;
        }

        .col-sm-3 {
            width: 80%;
            float: left;
        }
    </style>
}
<form id="form1" class="form-horizontal">
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="name">消息标题：</label>
                        <div class="col-sm-3">
                            <input class="form-control" style="width:300px;" maxlength="50" name="msgTtile" id="msgTtile"></input>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="name">消息类型：</label>
                        <div class="col-sm-3">
                            <select class="form-control" style="width:150px;" id="msgType">
                                <option value="1">预约</option>
                                <option value="2">通知消息</option>
                                <option value="3">其他</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="name">消息来源：</label>
                        <div class="col-sm-3">
                            <select class="form-control" style="width:150px;" id="msgSource">
                                <option value="1">系统自动</option>
                                <option value="2">OP系统</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="name">消息简介：</label>
                        <div class="col-sm-3">
                            <input type="text" class="form-control" style="width:300px;" name="msgDesc" maxlength="100" id="msgDesc" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="name">消息明细：</label>
                        <div class="col-sm-3">
                            <textarea type="text" rows="4" class="form-control" value="" style="width:300px;" maxlength="2000" name="msgBody" id="msgBody"></textarea>
                        </div>
                    </div>

                </div>
                <div class="box-footer text-center">
                    <button class="btn btn-primary" type="button" id="btnSave">确 定 </button>
                    <button class="btn" type="button" id="cancel">取 消 </button>
                </div>
            </div>

        </div>
        <!-- /.row -->
    </section>

</form>
@section scriptsBottom{
    <script type="text/javascript">
        $(document).ready(function () {
            initFormValidate();
            $("#btnSave").click(function () {
                save();
            });
            $("#cancel").click(function () {
                BMCW.closeTopLayer();
            });
        });
        function initFormValidate() {
            $("#form1").bootstrapValidator({
                submitHandler: function (valiadtor, loginForm, submitButton) {
                    valiadtor.defaultSubmit();
                },
                fields: {
                    msgTtile: {
                        validators: {
                            notEmpty: {
                                message: '消息标题不能为空'
                            }
                        }
                    },
                    msgType: {
                        validators: {
                            notEmpty: {
                                message: '请选择消息类别'
                            }
                        }
                    },
                    msgSource: {
                        validators: {
                            notEmpty: {
                                message: '请选择消息来源'
                            }
                        }
                    },
                    msgBody: {
                        validators: {
                            notEmpty: {
                                message: '消息详情不能为空'
                            }
                        }
                    },
                    msgDesc: {
                        validators: {
                            notEmpty: {
                                message: '消息描述不能为空'
                            }
                        }
                    },

                }
            });
        }

        function save() {
            var bootstrapValidator = $("#form1").data('bootstrapValidator');
            bootstrapValidator.validate();
            if (bootstrapValidator.isValid()) {
                BMCW.ajax({
                    url: '@Url.Action("Save","Message")',
                    type: "Post",
                    data: {
                        MessageTitle: $("#msgTtile").val(),
                        MessageBody: $("#msgBody").val(),
                        MessageType: $("#msgType").val(),
                        MessageSource: $("#msgSource").val(),
                        MessageDesc: $("#msgDesc").val()
                    },
                    success: function (o) {
                        if (o.status == 0) {
                            BMCW.msg("保存成功", function () {
                                BMCW.getTopSelectedWin().search();
                            });
                        } else {
                            BMCW.alert("保存失败");
                        }
                    }
                });
            }
        }
    </script>
}

